1 /* 2 * Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation version 2.1 of the License. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 17 * 18 */ 19 20 /** 21 * @file desc_extension.h 22 * @ingroup descriptors 23 * @brief Provides the descriptors for the extension descriptor. 24 * The extension descriptor is used to extend the 8-bit namespace 25 * of the descriptor_tag field. 26 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1) 27 * @author Mauro Carvalho Chehab 28 * 29 * @par Relevant specs 30 * The descriptor described herein is defined at: 31 * 32 * @see 33 * - ETSI EN 300 468 V1.11.1 34 * 35 * @par Bug Report 36 * Please submit bug reports and patches to linux-media@vger.kernel.org 37 */ 38 39 module libdvbv5_d.desc_extension; 40 41 import core.sys.posix.unistd; 42 43 import libdvbv5_d.descriptors: dvb_desc; 44 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms; 45 46 extern (C): 47 48 // struct dvb_v5_fe_parms; 49 50 /** 51 * @enum extension_descriptors 52 * @brief List containing all extended descriptors used by Digital TV MPEG-TS 53 * as defined at ETSI EN 300 468 V1.11.1 54 * @ingroup descriptors 55 * 56 * @var image_icon_descriptor 57 * @brief image icon descriptor 58 * 59 * @var cpcm_delivery_signalling_descriptor 60 * @brief Content Protection/Copy Management (CPCM) delivery signalling 61 * descriptor 62 * 63 * @var CP_descriptor 64 * @brief Content Protection descriptor 65 * 66 * @var CP_identifier_descriptor 67 * @brief Content Protection identifier descriptor 68 * 69 * @var T2_delivery_system_descriptor 70 * @brief DVB-T2 delivery system descriptor 71 * 72 * @var SH_delivery_system_descriptor 73 * @brief DVB-SH delivery system descriptor 74 * 75 * @var supplementary_audio_descriptor 76 * @brief supplementary audio descriptor 77 * 78 * @var network_change_notify_descriptor 79 * @brief network change notify descriptor 80 * 81 * @var message_descriptor 82 * @brief message descriptor 83 * 84 * @var target_region_descriptor 85 * @brief target region descriptor 86 * 87 * @var target_region_name_descriptor 88 * @brief target region name descriptor 89 * 90 * @var service_relocated_descriptor 91 * @brief service relocated descriptor 92 */ 93 enum extension_descriptors 94 { 95 image_icon_descriptor = 0x00, 96 cpcm_delivery_signalling_descriptor = 0x01, 97 CP_descriptor = 0x02, 98 CP_identifier_descriptor = 0x03, 99 T2_delivery_system_descriptor = 0x04, 100 SH_delivery_system_descriptor = 0x05, 101 supplementary_audio_descriptor = 0x06, 102 network_change_notify_descriptor = 0x07, 103 message_descriptor = 0x08, 104 target_region_descriptor = 0x09, 105 target_region_name_descriptor = 0x0a, 106 service_relocated_descriptor = 0x0b 107 } 108 109 /** 110 * @struct dvb_extension_descriptor 111 * @ingroup descriptors 112 * @brief Structure containing the extended descriptors 113 * 114 * @param type Descriptor type 115 * @param length Length of the descriptor 116 * @param next pointer to the dvb_desc descriptor 117 * @param extension_code extension code 118 * @param descriptor pointer to struct dvb_desc 119 */ 120 struct dvb_extension_descriptor 121 { 122 align (1): 123 124 ubyte type; 125 ubyte length; 126 dvb_desc* next; 127 128 ubyte extension_code; 129 130 dvb_desc* descriptor; 131 } 132 133 /** 134 * @brief Function prototype for the extended descriptors parsing init code 135 * @ingroup dvb_table 136 * 137 * @param parms Struct dvb_v5_fe_parms pointer 138 * @param buf buffer with the content of the descriptor 139 * @param ext struct dvb_extension_descriptor pointer 140 * @param desc struct dvb_desc pointer 141 */ 142 alias dvb_desc_ext_init_func = int function ( 143 dvb_v5_fe_parms* parms, 144 const(ubyte)* buf, 145 dvb_extension_descriptor* ext, 146 void* desc); 147 /** 148 * @brief Function prototype for the extended descriptors parsing print code 149 * @ingroup dvb_table 150 * 151 * @param parms Struct dvb_v5_fe_parms pointer 152 * @param buf buffer with the content of the descriptor 153 * @param ext struct dvb_extension_descriptor pointer 154 * @param desc struct dvb_desc pointer 155 */ 156 alias dvb_desc_ext_print_func = void function ( 157 dvb_v5_fe_parms* parms, 158 const(dvb_extension_descriptor)* ext, 159 const(void)* desc); 160 /** 161 * @brief Function prototype for the extended descriptors parsing free code 162 * @ingroup dvb_table 163 * 164 * @param desc struct dvb_desc pointer 165 */ 166 alias dvb_desc_ext_free_func = void function (const(void)* desc); 167 168 /** 169 * @struct dvb_ext_descriptor 170 * @ingroup descriptors 171 * @brief Structure that describes the parser functions for the extended 172 * descriptors. Works on a similar way as struct dvb_descriptor. 173 * 174 * @param name name of the descriptor 175 * @param init init dvb_desc_ext_init_func pointer 176 * @param print print dvb_desc_ext_print_func pointer 177 * @param free free dvb_desc_ext_free_func pointer 178 * @param size size of the descriptor 179 */ 180 struct dvb_ext_descriptor 181 { 182 const(char)* name; 183 dvb_desc_ext_init_func init; 184 dvb_desc_ext_print_func print; 185 dvb_desc_ext_free_func free; 186 ssize_t size; 187 } 188 189 /** 190 * @brief Initializes and parses the extended descriptor 191 * @ingroup descriptors 192 * 193 * @param parms struct dvb_v5_fe_parms pointer to the opened device 194 * @param buf buffer containing the descriptor's raw data 195 * @param desc pointer to struct dvb_desc to be allocated and filled 196 * 197 * This function allocates a the descriptor and fills the fields inside 198 * the struct. It also makes sure that all fields will follow the CPU 199 * endianness. Due to that, the content of the buffer may change. 200 * 201 * @return On success, it returns the size of the allocated struct. 202 * A negative value indicates an error. 203 */ 204 int dvb_extension_descriptor_init ( 205 dvb_v5_fe_parms* parms, 206 const(ubyte)* buf, 207 dvb_desc* desc); 208 209 /** 210 * @brief Prints the content of the extended descriptor 211 * @ingroup descriptors 212 * 213 * @param parms struct dvb_v5_fe_parms pointer to the opened device 214 * @param desc pointer to struct dvb_desc 215 */ 216 void dvb_extension_descriptor_print ( 217 dvb_v5_fe_parms* parms, 218 const(dvb_desc)* desc); 219 220 /** 221 * @brief Frees all data allocated by the extended descriptor 222 * @ingroup descriptors 223 * 224 * @param desc pointer to struct dvb_desc to be freed 225 */ 226 void dvb_extension_descriptor_free (dvb_desc* desc);